global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id NGINX_MASTER
}

vrrp_script check_nginx {
    script "/etc/keepalived/check_nginx.sh"
}

vrrp_instance VI_1 {
    state {{ hostvars[ansible_default_ipv4.address].vars.vrrp_instance_state }}
    interface {{ hostvars[ansible_default_ipv4.address].vars.interface }}  # 修改为实际网卡名
    virtual_router_id 51 # VRRP 路由 ID实例，每个实例是唯一的
    priority {{ hostvars[ansible_default_ipv4.address].vars.priority }}  # 优先级，备服务器设置 90
    advert_int 1    # 指定VRRP 心跳包通告间隔时间，默认1秒
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    # 虚拟IP
    virtual_ipaddress {
        {{ hostvars[ansible_default_ipv4.address].virtual_ipaddress }}
    }
    track_script {
        check_nginx
    }
}